# -*- coding: utf-8 -*-
import unittest

from helper import *
import base

class TestRegistrador(unittest.TestCase):

    def test_binToDec(self):
        self.assertEqual(binToDec('10'), '2')
        self.assertEqual(binToDec('10100'), '20')
        self.assertEqual(binToDec('11001'), '25')
        self.assertEqual(binToDec('100010'), '34')
        self.assertEqual(binToDec('11101010'), '234')
        self.assertEqual(binToDec('1000111010011'), '4563')
        self.assertEqual(binToDec('1101'), '13')
        self.assertEqual(binToDec('111'), '7')
        self.assertEqual(binToDec('1110'), '14')
        self.assertEqual(binToDec('1'), '1')
        self.assertEqual(binToDec('1111011011'), '987')
        self.assertEqual(binToDec('0'), '0')
        self.assertEqual(binToDec('1000011100001'), '4321')

    def test_decToBin(self):
        self.assertEqual('10', decToBin(2))
        self.assertEqual('10100', decToBin(20))
        self.assertEqual('11001', decToBin(25))
        self.assertEqual('100010', decToBin(34))
        self.assertEqual('11101010', decToBin(234))
        self.assertEqual('1000111010011', decToBin(4563))
        self.assertEqual('1101', decToBin(13))
        self.assertEqual('111', decToBin(7))
        self.assertEqual('1110', decToBin(14))
        self.assertEqual('1', decToBin(1))
        self.assertEqual('1111011011', decToBin(987))
        self.assertEqual('0', decToBin(0))
        self.assertEqual('1000011100001', decToBin(4321))
    
    def test_hexToBin(self):
        self.assertEqual(hexToBin('ABC'), '101010111100')
        self.assertEqual(hexToBin('0'), '0000')
        self.assertEqual(hexToBin('acc'), '101011001100')
        self.assertEqual(hexToBin('1234'), '0001001000110100')
        self.assertEqual(hexToBin('9df'), '100111011111')
        self.assertEqual(hexToBin('4e32'), '0100111000110010')
        self.assertEqual(hexToBin('123'), '000100100011')
        self.assertEqual(hexToBin('34'), '00110100')
        self.assertEqual(hexToBin('1'), '0001')
        self.assertEqual(hexToBin('FF'), '11111111')
        self.assertEqual(hexToBin('AC'), '10101100')
        self.assertEqual(hexToBin('FFDE'), '1111111111011110')
        
if __name__ == '__main__':
    unittest.main()
